package game.scene
{
	import engine.math.*;
	import game.actor.*;
	import game.asset.*;
	
	public class RxPathMover
	{
		private var m_path:Array;
		private var m_index:int;
		private var m_speed:Number;
		private var m_speedStack:Array;
		private var m_closestNode:int;
		private var m_currPos:RxVector4;
		private var m_startPos:RxVector4;
		private var m_deltaPos:RxVector4;
		private var m_endPos:RxVector4;
		private var m_segmentTime:Number;
		private var m_currSegmentTime:Number;
		private var m_atEnd:int;
		private var m_distanceTravelled:Number;
		private var m_totalDistance:int;
		private var m_posError:RxVector4;
		private var m_currPosPlusError:RxVector4;
		private var m_nav:RxAssetNavNode;
		private var m_actor:RxActorState;
		private var m_sequenceNumber:uint;
		private static var s_sequenceNumber:uint = 0;
		
		public function RxPathMover(path:Array, speed:Number, state:RxActorState = null)
		{
			this.m_speedStack = new Array();
			this.m_currPos = new RxVector4();
			this.m_startPos = new RxVector4();
			this.m_deltaPos = new RxVector4();
			this.m_endPos = new RxVector4();
			this.m_posError = new RxVector4();
			this.m_currPosPlusError = new RxVector4();
			this.m_actor = state;
			this.m_sequenceNumber = s_sequenceNumber + 1;
			this.m_nav = RxAssetNavNode.GetByName("navnode");
			this.m_path = path;
			this.m_speed = speed;
			this.m_atEnd = 1;
			this.m_index = 0;
			if (this.m_path != null)
			{
				if (state != null && state.GetPlayerIndex() == 1)
				{
				}
				this.m_startPos.Copy(this.m_nav.GetNodePos(this.m_path[this.m_index]));
				this.init_segment();
			}
			this.m_currSegmentTime = 0;
			this.resetDistance();
			this.m_closestNode = this.m_path[this.m_index];
		}
		
		private function init_segment() : void
		{
			
		}
		
		private function resetDistance() : void
		{
			var i:int = 0;
			this.m_distanceTravelled = 0;
			this.m_totalDistance = 0;
			if (this.m_path != null && this.m_nav != null)
			{
				i = 0;
				while (i < (this.m_path.length - 1))
				{
					
					this.m_totalDistance = this.m_totalDistance + RxVector4.Distance3(this.m_nav.GetNodePos(this.m_path[(i + 1)]), this.m_nav.GetNodePos(this.m_path[i]));
					i++;
				}
			}
		}
	}
}